{% extends "base.html"%}
{% import "bootstrap/wtf.html" as wtf %}

{% block title %}学生信息列表{% endblock %}

{% block page_content %}
<div class="container">
    {% for message in get_flashed_messages() %}
    <div class="alert alert-warning">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        {{ message }}
    </div>
    {% endfor %}
</div>
<div class="page-header">
    <h1>Student Records</h1>
    <a href="{{ url_for('new_stud') }}" class="btn btn-primary">New Record</a>
</div>

<!-- 显示学生数量和列表 -->
<h4>{{ studs|length }} students</h4>
{% for stud in studs %}
<div class="well">
    <p>ID: {{ stud.student_id }} | 姓名: {{ stud.student_name }}</p>
    <!-- 编辑按钮：跳转到编辑页 -->
    <a href="{{ url_for('edit_stud', stu_id=stud.student_id) }}" class="btn btn-success">Edit</a>
    <!-- 删除按钮：用表单提交（避免直接URL删除） -->
    <form action="{{ url_for('del_stud', stud_id=stud.student_id) }}" method="POST" style="display: inline;">
        {{ delete_form.hidden_tag() }}  <!-- 安全验证，必须加 -->
        {{ wtf.form_field(delete_form.submit, class="btn btn-danger") }}
    </form>
</div>
{% endfor %}
{% endblock %}
